#lang racket

(define (id x) x)

(define (inc x) (+ x 1))

(define (accumulate-rec combiner null-value term a next b)
  (if (> a b)
      null-value
      (combiner (term a)
         (accumulate-rec combiner null-value term (next a) next b))))

(define (accumulate-iter combiner null-value term a next b)
  (define (iter a result)
    (if (> a b)
        result
        (iter (next a) (combiner result (term a)))))
  (iter a null-value))

(define (sum term a next b) (accumulate-iter + 0 term a next b))

(define (product term a next b) (accumulate-iter * 1 term a next b))

(sum id 1 inc 10)

(product id 1 inc 6)